package com.ittx.dzt.ali.health.factory;

import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
 *  sdk-client构建工厂
 * <p>
 *
 * </p>
 * @author wl_code@163.com
 * @date 2025/2/7
 * @version 1.0
 */
public class TbSdkClientFactory {

    private static ConcurrentMap<String, TaobaoClient> clients = new ConcurrentHashMap<>();

    /**
     * 获取client对象
     *
     * @param appKey    appKey
     * @param appSecret app密钥
     * @param url       sdk地址
     * @return client对象
     */
    public static TaobaoClient getTaobaoClient(String url, String appKey, String appSecret) {
        if (clients.containsKey(appKey)) {
            return clients.get(appKey);
        }
        TaobaoClient client = new DefaultTaobaoClient(url, appKey, appSecret);
        clients.put(appKey, client);
        return client;
    }

}
